package com.gxa.user.controller;/**
 * @author JunYu
 * @create 2022-10-09--14:55
 */

import com.gxa.common.result.R;
import com.gxa.user.service.order.OrderService;
import com.gxa.user.vo.OrderInfo;
import com.gxa.user.vo.OrderList;
import org.aspectj.weaver.ast.Or;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.http.MediaType;
import org.springframework.web.bind.annotation.*;
import org.w3c.dom.ls.LSInput;

import java.util.ArrayList;
import java.util.List;
import java.util.Map;

/**
 * @program: take-out-project-shop
 *
 * @description: 订单控制器
 *
 * @author: JunYu
 *
 * @create: 2022-10-09 14:55
 **/
@RestController
@CrossOrigin
public class OrderController {
    @Autowired
    OrderService service;

    @PostMapping(value = "/createTakeOutOrder",produces = MediaType.APPLICATION_JSON_UTF8_VALUE)
    public R createOrder(@RequestBody OrderInfo orderInfo) {
        R r = service.createTakeOutOrder(orderInfo);
        return r;
    }
    @PostMapping(value = "/findAllOrders",produces = MediaType.APPLICATION_JSON_UTF8_VALUE)
    public R createOrder(@RequestBody Map<String,String> map) {
        R r = new R();
        List<OrderList> list = new ArrayList<>();
        OrderList order = new OrderList();
        order.setId(Long.getLong(map.get("id")));
        order.setName("测试");
        order.setMoney(123.45f);
        order.setNum(213123);
        order.setStatus(1);
        list.add(order);
        r.setData(list);
        r.setCode(200);
        r.setMessage("查询成功");
        return r;
    }
}
